package com.example.bootdemo.common.exception;

import com.example.bootdemo.common.enums.ResultCodeEnum;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;

/**
 * 业务异常
 */
@Getter
@Setter
public class BusinessException extends RuntimeException{

    private ResultCodeEnum resultCodeEnum;

    public BusinessException(String msg) {
        super(msg);
        ResultCodeEnum parameterError = ResultCodeEnum.BUSINESS_ERROR;
        if (StringUtils.isNotBlank(msg)){
            parameterError.setMessage(msg);
        }
        this.resultCodeEnum = parameterError;
    }
    public BusinessException(ResultCodeEnum codeEnum) {
        this.resultCodeEnum = codeEnum;
    }
}
